//package com.lwq.imserver.model.proto;
//
//import com.lwq.imserver.constants.ChannelAttr;
//import com.lwq.imserver.model.HeartBeats;
//import com.lwq.imserver.model.SendBody;
//import io.netty.buffer.ByteBuf;
//import io.netty.buffer.ByteBufInputStream;
//import io.netty.channel.ChannelHandlerContext;
//import io.netty.handler.codec.MessageToMessageDecoder;
//import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
//
//import java.io.InputStream;
//import java.util.List;
//
//public class WebMessageDecoder extends MessageToMessageDecoder<BinaryWebSocketFrame> {
//
//    @Override
//    protected void decode(ChannelHandlerContext context, BinaryWebSocketFrame frame, List<Object> list) throws Exception {
//
//        context.channel().attr(ChannelAttr.PING_COUNT).set(null);
//
//        ByteBuf buffer = frame.content();
//
//        byte type = buffer.readByte();
//
//        if (Constant.DATA_TYPE_PONG == type) {
//            list.add(HeartBeats.PONG);
//            return;
//        }
//
//        InputStream inputStream = new ByteBufInputStream(buffer);
//
//        SentBodyProto.Model bodyProto = SentBodyProto.Model.parseFrom(inputStream);
//
//        SendBody body = new SendBody();
//        body.setKey(bodyProto.getKey());
//        body.setTimestamp(bodyProto.getTimestamp());
//        body.putAll(bodyProto.getDataMap());
//
//        list.add(body);
//    }
//}
